<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 1.如果是两层for循环，就输出两个数的组合
        // 2.如果是三层for循环，就输出3个数的组合
        function combine(m, k) {
            let n = 0
            let result = []
            let arr = []
            for (let i = 1; i <= m; i++) {
                arr.push(i)
            }
            console.log(arr);
            // 这个结果老是输入出来不对哇
            for (i = 0; i < m; i++) {
                for (let j = i + 1; j < m; j++) {
                    for (let u = j + 1; u < m; u++) {
                        result.push([arr[i], arr[j], arr[u]])
                    }
                }
            }
            return result
        }
        console.log(combine(4, 3));
    </script>
</body>

</html>